﻿@{
    ViewBag.Title = "5 冲压件成品库入库统计表";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<script>
    var moduleId = $.request("moduleId");
    var tempdata = 0;
    $(function () {
        initControl();
        gridList1();
        tempdata = 1;
        })
        function initControl() {
            $('select').bindSelect();
            $("#ZSJ_B1_GH_SI").bindSelect({
                url: "/BaseData/ZSJ_B1_GH_SI/GetGridJson",
                id: "UnitID",
                text: "UnitNOShortName"
            });
                    //显示台账日期
            var keyValue = $.request("keyValue");
            $.ajax({
                url: "/WareHouse/EnterWareHouse/GetInfoDocumentNum",
                data: { keyValue: keyValue },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                    $("#txt_FAccountDate").val(data);
                    if (data == currentDate.format("yyyyMM")) {
                        tempdata = 1;
                    }
                    else { tempdata = 3; }
                }
            });
            //零件分类
            $("#txt_FProductionTypeName").bindSelect({//FClassNO ='01'
                url: "/VBaseData/V_BUS_SJ_Dictionary/GetSJ_DictionaryEntity",
                id: "UseUnit",
                text: "FTypeName",
            });

            //供货单位名称
            $("#txt_FProCompanyNO").bindSelect({
                url: "/BaseData/ZSJ_B1_GH_SI/GetGridJson?isProduct=1",
                id: "UnitNO",
                text: "UnitNOShortName"
            });
            $('.category').on("click", function () {
                var aa = $("input[type='radio'].category:checked").val();
                if (aa == '零件') {
                    gridList1();
                    tempdata = 1;
                }
                else {
                    gridList2();
                    tempdata = 2;
                }
            });
        }
        function gridList1() {
            $("#grid1").show();
            $("#grid2").hide();
            var $gridList = $("#gridList1");
            $gridList.dataGridForJson({
            url: "/VBaseData/V_CPK_44_MX_StoCPKListAcco_Mid_MX/GetGridJson",
                        height: $(window).height() - 120,
                        colModel: [
                        { label: '来料单位', name: 'FHappenComNO', width: 220, align: 'left', sortable: false },
                        { label: '零件编号', name: 'FProductionNO', width: 220, align: 'left', sortable: false },
                        { label: '零件名称', name: 'FProductionName', width: 220, align: 'left', sortable: false },
                        { label: '入库数量', name: 'BYSL', width: 100, align: 'right', sortable: false },
                        { label: '计划单价', name: 'JHDJ', width: 100, align: 'right', sortable: false },

                        { label: '入库金额', name: 'BYJHJE', width: 100, align: 'right', sortable: false },
                        { label: '供货单位', name: 'FProCompanyName', width: 220, align: 'left', sortable: false },
                        { label: '零件分类', name: 'FProductionTypeName', width: 100, align: 'left', sortable: false },
                        ],
                        pager: "#gridPager1",
                        sortname: 'FProductionNO asc',
                        viewrecords: true,
                        onSelectRow: function (rowId) {
                            rowData = $gridList.jqGrid('getRowData', rowId);
                            index = rowId;
                            $.each(rowData, function (key, value) {
                                $("#txt" + key).val(value);
                            });
                        }
                    });
                    $("#btn_search").click(function () {
                        $gridList.jqGrid('setGridParam', {
                            postData: { keyword: $("#txt_FDocuTypeNO").val() },
                        }).trigger('reloadGrid');
                    });
        }

        function gridList2() {
            $("#grid1").hide();
            $("#grid2").show();
            var $gridList = $("#gridList2");
            $gridList.dataGridForJson({
             //   url: "/VBaseData/V_CPK_11_DJ_StoRegister/GetGridJson?moduleId=" + moduleId,
                height: $(window).height() - 120,
                colModel: [
                        { label: '零件分类', name: 'FProductionTypeName', width: 90, align: 'left' },
                        { label: '期初库存', name: 'FQuantity_QC', width: 90, align: 'right' },
                        { label: '期初金额', name: 'FQuantity_QCJE', width: 90, align: 'right' },
                        { label: '入库数量', name: 'FQuantity_RK', width: 90, align: 'right' },
                        { label: '入库金额', name: 'FQuantity_RKJE', width: 90, align: 'right' },
                        { label: '出库数量', name: 'FQuantity_CK', width: 90, align: 'right' },

                        { label: '出库金额', name: 'FQuantity_CKJE', width: 90, align: 'right' },
                        { label: '废品数量', name: 'FQuantity_FP', width: 90, align: 'right' },
                        { label: '废品金额', name: 'FQuantity_FPJE', width: 90, align: 'right' },
                        { label: '返修数量', name: 'FQuantity_FX', width: 90, align: 'right' },
                        { label: '返修金额', name: 'FQuantity_FXJE', width: 90, align: 'right' },

                        { label: '盈亏数量', name: 'FQuantity_PC', width: 80, align: 'right' },
                        { label: '盈亏金额', name: 'FQuantity_PCJE', width: 80, align: 'right' },
                        { label: '期末库存', name: 'FQuantity_JC', width: 80, align: 'right' },
                        { label: '期末金额', name: 'FQuantity_JCJE', width: 80, align: 'right' }

                ],
                pager: "#gridPager2",
                sortname: 'FProductionTypeName asc',
                viewrecords: true,
                onSelectRow: function (rowId) {
                    rowData = $gridList.jqGrid('getRowData', rowId);
                    index = rowId;
                    $.each(rowData, function (key, value) {
                        $("#txt" + key).val(value);
                    });
                }
            });
            $("#btn_search").click(function () {
                $gridList.jqGrid('setGridParam', {
                    postData: { keyword: $("#txt_FDocuTypeNO").val() },
                }).trigger('reloadGrid');
            });
    }
        function btn_Excel() {
            alert($("#txt_FProCompanyNO").val());
            alert($("#txt_FProCompanyNO").value());
        //$.detailOpen({
        //    id: "Detail",
        //    title: "",
        //    url: "/WareHouse/Export/WareHouseNoticeExcel"
        //});
    }
    function btn_Print() {
        $.detailOpen({
            id: "Detail",
            title: "",
            url: "/WareHouse/Print/WareHouseNoticePrint"
        });
    }
    function btn_Search() {
        if (tempdata == 1)  {
            gridListSearch($("#gridList1"))
        }
        else if (tempdata == 2) {
            gridListSearch($("#gridList2"))
        }
    }

    function gridListSearch(obj) {
        obj.jqGrid('setGridParam', {
            postData: {//台账日期faccountDate,零件编号fproductionNo, 零件名称fproductionName,供货单位 fproCompanyNO,零件分类fproductionTypeName
                faccountDate: $("#txt_FAccountDate").val(), fproductionNo: $("#txt_FProductionNO").val(),
                fproductionName: $("#txt_FProductionName").val(), fproCompanyNO: $("#txt_FProCompanyNO").val(), fproductionTypeName: $("#txt_FProductionTypeName").val()
            },
        }).trigger('reloadGrid');
    }
</script>
<body>
    <div id="layout" style="height: 100%; width: 100%;">
        <form id="form1">
            <div style="padding: 12px 0 5px 0; padding-left:15px; border-bottom:1px solid #ccc;margin-top:-10px;" class="line-table input-width-185">
                <div class="updowninput btn-group" style="margin-top:0px;">
                    <input id="radio11" class="category" name="category" value="零件" checked="checked" type="radio">
                    <label for="radio11" class="suffix">自制</label><br>
                    <input id="radio12" class="category" name="category" value="分类" type="radio">
                    <label for="radio12" class="suffix">外协</label>
                </div>
                <div class="btn-group" style="margin-top:0px;margin-left:20px;">
                    来料单位<br />
                    <select id="txt_FProCompanyNO" name="" class="form-control">
                        <option value="">==请选择==</option>
                    </select>
                    &nbsp;
                </div>
                <div class="btn-group" style="margin-top:0px;">
                    制造单位<br />
                    <select id="txt_FProductionTypeName11111111111" name="F_DutyId" class="form-control">
                        <option value="">==请选择==</option>
                    </select>
                    &nbsp;
                </div>
                <div class="btn-group" style="margin-top:0px;">
                    零件分类<br />
                    <select id="txt_FProductionTypeName" name="F_DutyId" class="form-control">
                        <option value="">==请选择==</option>
                    </select>
                    &nbsp;
                </div>
                <div class="btn-group" style="margin-top:0px;">
                    零件编号<br />
                    <input id="txt_FProductionNO" name="" placeholder="" type="text" class="form-control required input-width-105" />
                    &nbsp;
                </div>
                <div class="btn-group" style="margin-top:0px;">
                    零件名称<br />
                    <input id="txt_FProductionName" name="" placeholder="" type="text" class="form-control required input-width-105" />
                    &nbsp;
                </div>
                @*<div class="btn-group" style="margin-top:0px;margin-left:50px;">
                台账日期<br />
                <input id="txt_FAccountDate" name="" placeholder="" type="text" class="form-control required" onfocus="WdatePicker({ dateFmt: 'yyyyMM', isShowToday: false, isShowClear: false });" />
                &nbsp;
            </div>*@
                <div class="btn-group" style="margin-top:12px;margin-left:10px;">
                    &nbsp;
                    <a id="" class="btn btn-primary center-block" onclick="btn_Search()"><span class="glyphicon glyphicon-search"></span>  &nbsp; 查询</a>
                </div>

                <div class="btn-group" style="float:right;margin-top:12px;">
                    <a class="btn btn-primary center-block" onclick="$.reload()">  <span class="glyphicon glyphicon-refresh"> </span>&nbsp刷新</a>
                    <a class="btn btn-primary center-block" onclick="btn_Excel()"> <span class="glyphicon glyphicon-download"></span>&nbsp导出</a>
                    <a class="btn btn-primary center-block" onclick="btn_Print()"> <span class="glyphicon glyphicon-print">   </span>&nbsp打印</a>
                </div>
            </div>
        </form>
        <div id="grid1">
            <table id="gridList1"></table>
            <div id="gridPager1"></div>
        </div>
        <div id="grid2">
            <table id="gridList2"></table>
            <div id="gridPager2"></div>
        </div>
    </div>
</body>